#ifndef SNAKE_H
#define SNAKE_H

#include <QMainWindow>
#include<qpainter.h>
#include<QVector>
#include<qstring.h>
#include <QtCore/QTextStream>
#include <QtCore/QFile>
#include <QtCore/QIODevice>
#include <QMutex>
namespace Ui {
class Snake;
}

class Snake : public QMainWindow
{
    Q_OBJECT

public:
    explicit Snake(QWidget *parent = 0);
    ~Snake();
    void paintEvent(QPaintEvent *event);
    void InitSnake();
    QRect CreateRect();
    void IsEat();
    void IsHit();
    float sp=4;bool ifp=1;

private slots:
    void Snake_update();
private:
    Ui::Snake *ui;
    QVector<QRect> vSnakeRect;
    QRect SnakeHead;
    void keyPressEvent(QKeyEvent *key);
    QTimer *timer;
    bool blsRun;
    bool blsOver;
    QString sDisplay;
    int nDirection;
    QRect food;
    int nScore;
    int snakelenth;
    QString scoreLabel;
    QString snakeLabel;
    QString vLabel;
    int speed;
};

#endif // SNAKE_H

